package com.risetek.tft.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * TOperate entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "T_SYS_OPERATE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TOperate implements java.io.Serializable {

	// Fields

	private TOperateId id;
	private TMenu TMenu;
	private String name;
	private String icon;
	private String remark;
	private Integer ordno;
	private Boolean isshow;
	private Set<TRole> TRoles = new HashSet<TRole>(0);

	// Constructors

	/** default constructor */
	public TOperate() {
	}

	/** minimal constructor */
	public TOperate(TOperateId id, TMenu TMenu, String name, Boolean isshow) {
		this.id = id;
		this.TMenu = TMenu;
		this.name = name;
		this.isshow = isshow;
	}

	/** full constructor */
	public TOperate(TOperateId id, TMenu TMenu, String name, String remark,
			Integer ordno, Boolean isshow, Set<TRole> TRoles) {
		this.id = id;
		this.TMenu = TMenu;
		this.name = name;
		this.remark = remark;
		this.ordno = ordno;
		this.isshow = isshow;
		this.TRoles = TRoles;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "MENU", column = @Column(name = "MENU", nullable = false)),
			@AttributeOverride(name = "OP", column = @Column(name = "OP", nullable = false, length = 50)) })
	public TOperateId getId() {
		return this.id;
	}

	public void setId(TOperateId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MENU", nullable = false, insertable = false, updatable = false)
	public TMenu getTMenu() {
		return this.TMenu;
	}

	public void setTMenu(TMenu TMenu) {
		this.TMenu = TMenu;
	}

	@Column(name = "NAME", nullable = false, length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "ICON", length = 20)
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@Column(name = "REMARK", length = 2000)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "ORDNO")
	public Integer getOrdno() {
		return this.ordno;
	}

	public void setOrdno(Integer ordno) {
		this.ordno = ordno;
	}

	@Column(name = "ISSHOW", nullable = false)
	public Boolean getIsshow() {
		return this.isshow;
	}

	public void setIsshow(Boolean isshow) {
		this.isshow = isshow;
	}

	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name = "T_SYS_ROLE_OPERATE", joinColumns = { @JoinColumn(name = "menu", nullable = false, updatable = false), @JoinColumn(name = "op", nullable = false, updatable = false) }, 
	inverseJoinColumns = { @JoinColumn(name = "role", nullable = false, updatable = false) })
	public Set<TRole> getTRoles() {
		return this.TRoles;
	}

	public void setTRoles(Set<TRole> TRoles) {
		this.TRoles = TRoles;
	}

}